package com.dzzw.Servlet.DepartmentServlet;

import com.dzzw.Dao.DepartmentDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/View/DepartmentDeleteServlet")
public class DepartmentDeleteServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        int department_id = Integer.parseInt(request.getParameter("department_id"));
        DepartmentDao departmentDao = new DepartmentDao();
        departmentDao.DepartmentDelete(department_id);
        System.out.println("部门信息删除成功！");
        response.sendRedirect("View/SelectAllDepartment.jsp");
    }
}
